package entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;

@Entity
@Table(name = "Document")
public class Document implements Serializable {

    private Integer id_document;
    private String titre;
    private Avis avis;
    private Tache tache;
    private Date dateUpload;
    private Utilisateur proprietaire;

    public Document() {
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Integer getId() {
        return id_document;
    }

    public void setId(Integer id_document) {
        this.id_document = id_document;
    }

    @Column(name = "TITRE", nullable = false, updatable = false)
    @Size(min = 1, max = 50)
    public String getTitre() {
        return titre;
    }

    public void setTitre(String titre) {
        this.titre = titre;
    }

    @JoinColumn(name = "AVIS", nullable = true, updatable = false)
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "document", optional = true)
    public Avis getAvis() {
        return avis;
    }

    public void setAvis(Avis avis) {
        this.avis = avis;
    }

    @JoinColumn(name = "TACHE", nullable = true, updatable = false)
    @ManyToOne
    public Tache getTache() {
        return tache;
    }

    public void setTache(Tache tache) {
        this.tache = tache;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "DATE_UPLOAD", nullable = false)
    public Date getDateUpload() {
        return dateUpload;
    }

    public void setDateUpload(Date dateUpload) {
        this.dateUpload = dateUpload;
    }

    @JoinColumn(name = "PROPRIETAIRE", nullable = false, updatable = false)
    @ManyToOne
    public Utilisateur getProprietaire() {
        return proprietaire;
    }

    public void setProprietaire(Utilisateur proprietaire) {
        this.proprietaire = proprietaire;
    }

}
